#include <head.h>
typedef struct times
{
    int year_d;
    char year[128];
    int mon_d;
    char mon[128];
    int day_d;
    char day[128];
    int hour;
    char m;
    int min;
    char n;
    int sec;
    
} times;

int main(int argc, char const *argv[])
{
    char buffer[128];
    int fd = open("time.txt", O_RDWR | O_TRUNC | O_CREAT, 0666);
    lseek(fd, 0, SEEK_SET);
    time_t current_time;
    time(&current_time);
    struct tm *loc_time = localtime(&current_time);
    while (1)
    {    time(&current_time);
    loc_time = localtime(&current_time);
           strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S\n", loc_time);
   printf("Formatted local time: %s", buffer);
     write(fd, buffer,strlen(buffer));
    sleep(1);
    }
    

    close(fd);
    return 0;
}
